﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebSysCore;

namespace HSchSchedule.FrontPage
{
    public partial class LoginPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private void Login()
        {
            string userName = txtUser.Text;
            string password = txtPassword.Text;
            List<User> lstAllUser = DataBase.GetAllUser();
            bool ok = false;
            foreach (User c in lstAllUser)
            {

                if (c.UserName.CompareTo(userName) == 0 && c.Password.CompareTo(password) == 0)
                {
                    ok = true;
                    Response.Redirect("~/FrontPage/CustomerManage.aspx");
                }
                else
                {
                    ok = false;
                }
            }
            if (!ok)
            {
                lblError.Text = "Loi login";
            }

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            // throw new NotImplementedException();
            Login();
        }
    }
}
